package com.qf.service;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.qf.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

/**
 * @author 汤奇
 * @version V1.0
 * @Project BookPro
 * @Package com.qf.service
 * @Description:
 * @Date 2022/7/12 13:15
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private RestTemplate restTemplate;

    @Override
    @Transactional
    @LcnTransaction
    public void aReduce() {
        //1.a账户减500
        userMapper.aReduce();

        //2.b账户加500
        restTemplate.getForObject("http://localhost:8081/b/add" ,String.class);
    }
}
